import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-04-24
 * Time: 0:17
 */
public class Main {
    public static void main(String[] args) {
        int l = 0,m = 0;
        Scanner scanner = new Scanner(System.in);
        l = scanner.nextInt();
        m = scanner.nextInt();
        int count = 0;
        int[] arr = new int[l+10];
        while(m > 0) {
            int head = 0;
            int tail = 0;
            head = scanner.nextInt();
            tail = scanner.nextInt();
            for(int i = head; i <= tail; i++) {
                arr[i] = 1;
            }
            m--;
        }
        for(int i = 0; i <= l; i++) {
            if(arr[i] == 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}
